from selenium import webdriver
import time
from data import Data
from unittest import TestCase
from ddt import ddt,data,unpack
from Login import Login
from copy方法 import Copy

c = Data()
d = Copy()
@ddt
class TestLogin(TestCase):
    @data(*c.success_a())
    @unpack
    def testLogin_Success(self,username,password,message,re):
        driver = webdriver.Chrome()
        driver.get("http://ehr.ibizlab.cn/")

        X = Login(driver)
        X.login(username,password)
        time.sleep(3)
        result = X.get_success()
        driver.quit()
        if result == message:
            d.cop(re)
        else:
            d.coy(re)
        self.assertEqual(message,result,"这都能错？？？")

    @data(*c.error_a())
    @unpack
    def testLogin_Error(self,username,password,message,re):
        driver = webdriver.Chrome()
        driver.get("http://ehr.ibizlab.cn/")

        X = Login(driver)
        X.login(username, password)
        time.sleep(3)
        result = X.get_Error()
        driver.quit()
        if result == message:
            d.cop(re)
        else:
            d.coy(re)
        self.assertEqual(message, result, "这都能错？？？")


